<?php
if (!defined('IN_XLP')) {
    exit('Access Denied');
}
$Document = array(
    'pageid' => 'goods-cateEdit', //页面标示
    'pagename' => '产品分类编辑', //当前页面名称
    'mycss' => array(), //加载的css样式表
    'myjs' => array(), //加载的js脚本
	//'footerjs'=>array('content/highcharts', 'content/exporting',),
	  'footerjs'=>array('content/fuelux/fuelux', 'content/combodate/moment.min'),
    'head' => true, //加载头部文件
);

include getTpl('header', 'public');
?>
<!--顶部导航 开始-->
<?php include getTpl('top', 'public');?>
<!--顶部导航 结束-->
<!--左侧菜单 开始-->
<?php include getTpl('nav', 'public');?>
<!--左侧菜单 结束-->
<!--主体 开始-->
<!-- content -->
  <section id="content">
	<section class="main padder"> 
    <div class="clearfix"> 
     <h4><i class="fa fa-edit"></i>分类编辑</h4> 
    </div> 
    <div class="row"> 
     <div class="col-sm-12"> 
      <section class="panel"> 
       <div class="panel-body"> 
        <form class="form-horizontal" id="cateAddForm" method="post" > 

         <div class="form-group"> 
          <label class="col-sm-1 control-label">分类名称</label> 
          <div class="col-sm-3"> 
            <input type="text" name="name" id="name" placeholder="分类名称" class="form-control" data-required="true"  value="<?php echo $cate['name'] ?>" />
          </div> 
         </div> 
         
         <div class="form-group"> 
          <label class="col-sm-1 control-label">副标题</label> 
          <div class="col-sm-3"> 
            <input type="text" name="sub_title" id="sub_title" placeholder="副标题" class="form-control" data-required="true"  value="<?php echo $cate['sub_title'] ?>"/>
          </div> 
         </div>


         <div class="form-group"> 
          <label class="col-sm-1 control-label">简介</label> 
          <div class="col-sm-3"> 
            <input type="text" name="brief" id="brief" placeholder="简介" class="form-control" data-required="true"  value="<?php echo $cate['brief'] ?>"/>
          </div> 
         </div>

         <div class="form-group"> 
          <label class="col-sm-1 control-label">交易详情</label> 
          <div class="col-sm-3"> 
            <textarea class="form-control"  name="content" id="content" style="height:100px"><?php echo $cate['content'] ?></textarea>
          </div> 
         </div>

         <div class="form-group"> 
          <label class="col-sm-1 control-label">交易时间</label> 
          <div class="col-sm-3"> 
            <input type="text" name="trade_time" id="trade_time" placeholder="交易时间" class="form-control" data-required="true" value="<?php echo $cate['trade_time'] ?>"/>
          </div> 
         </div>

          <div class="form-group"> 
            <label class="col-sm-1 control-label">背景图</label> 
            <div class="col-sm-3">
                <input type="text" name="back_img" id="back_img" placeholder="" class="form-control"  value="<?php echo $cate['back_img'] ?>" />
                <span class="help-block">
                  请上传背景图片，标准尺寸640px*705px
                  <?php if($cate['back_img']){?><a href="<?php echo getImgUrl($cate['back_img']);?>" rel="pop"> 预览>></a><?php }?>
                </span>
            </div>
            <div class="col-sm-3">
              <iframe width="280" height="24" src="<?php echo U('upload/index',array('id'=>'back_img')); ?>" scrolling="no" frameborder="0"></iframe>
            </div>
         </div>

         <div class="form-group"> 
          <label class="col-sm-1 control-label">是否显示</label> 
            <div class="row">
              <div class="col-xs-1 radio m-l-large"><label class="radio-custom"> 
              <input type="radio" name="is_show" <?php if($cate['is_show']==1){  ?>checked="checked" <?php } ?> value="1" /> <i class="fa fa-circle-o"></i>显示</label></div>
              <div class="col-xs-1 radio m-l-large"><label class="radio-custom"> 
              <input type="radio" name="is_show" <?php if($cate['is_show']==2){  ?>checked="checked" <?php } ?> value="2" /> <i class="fa fa-circle-o"></i>隐藏</label></div>
            </div>
         </div> 

         <div class="form-group"> 
          <label class="col-sm-1 control-label">排序</label> 
          <div class="col-sm-2"> 
            <input type="number" name="sort"  id="sort" placeholder="" class="form-control" value="255" value="<?php echo $cate['sort'] ?>"/>
          </div> 
         </div> 

         <div class="form-group"> 
          <div class="col-sm-9 col-lg-offset-3"> 
            <input type="hidden" name="id" value="<?php echo $cate['id'] ?>">
            <div class="col-sm-1"><button type="submit" id="sub-ok" data-loading-text="正在提交..." class="btn btn-primary">保存</button></div>
            <button type="button" class="btn btn-white col-md-offset-1">取消</button> 
          </div> 
         </div> 
        </form> 
       </div> 
      </section>
     </div> 
    </div> 
   </section> 
  </section> 
  <!--/ content --> 
<!--主体 结束-->
<script>
$(function(){
  $('#cateAddForm').submit(function(){

    if (!$('#name').val()){
      Msg.error('请输入分类名称');
      resetSubmit("#sub-ok",'提交');
      return false;
    }
   
    if (!$('#brief').val()){
      Msg.error('请输入产品简介');
      resetSubmit("#sub-ok",'提交');
      return false;
    }


    // if (!$('#content').val()){
    //   Msg.error('请输入交易详情');
    //   resetSubmit("#sub-ok",'提交');
    //   return false;
    // }

    Msg.loading();
    $.post('<?php echo U('goods/cateEdit');?>',$(this).serialize(),function(result){
      Msg.hide();
      resetSubmit("#sub-ok",'提交');
      if (result.status==1){
      Msg.ok(result.info);  
    }else{
      Msg.error(result.info);
    }
    },'json');
    return false;
  });

})
</script>
<?php
include getTpl('footer', 'public');
?>